package com.dream.vo.stock;

import java.io.Serializable;

import javax.validation.GroupSequence;
import javax.validation.constraints.Pattern;

import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.constraints.NotBlank;

import com.dream.model.stock.StockExpress;
import com.dream.utils.check.PatternExpConstants;
import com.dream.vo.base.First;
import com.dream.vo.base.FirstGroup;
import com.dream.vo.base.Second;
import com.dream.vo.base.Third;

@GroupSequence({First.class, Second.class,Third.class, StockExpressVO.class})  
public class StockExpressVO  implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3638438592332363500L;

	private Long requestId;
	
	private Long expressType;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String expressNo;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String fromName;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String fromAddress;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String fromUser;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String fromContact;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String toName;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String toAddress;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String toUser;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	private String toContact;
	
	private String toZip;
	
	@NotBlank(message = "err0001",groups = {First.class,FirstGroup.class})
	@Pattern(regexp = PatternExpConstants.NUM_PAT, message = "err0020",groups = {Second.class,FirstGroup.class})
	private String number;
	
	@Pattern(regexp = PatternExpConstants.FLOAT_PAT, message = "err0020",groups = {First.class,FirstGroup.class})
	private String cost;
	
	@Pattern(regexp = PatternExpConstants.FLOAT_PAT, message = "err0020",groups = {First.class,FirstGroup.class})
	private String weight;
	
	private String size;
	
	private String comments;
	
	public Long getRequestId() {
		return requestId;
	}

	public void setRequestId(Long requestId) {
		this.requestId = requestId;
	}

	public Long getExpressType() {
		return expressType;
	}

	public void setExpressType(Long expressType) {
		this.expressType = expressType;
	}

	public String getExpressNo() {
		return expressNo;
	}

	public void setExpressNo(String expressNo) {
		this.expressNo = expressNo;
	}

	public String getFromName() {
		return fromName;
	}

	public void setFromName(String fromName) {
		this.fromName = fromName;
	}

	public String getFromAddress() {
		return fromAddress;
	}

	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}

	public String getFromUser() {
		return fromUser;
	}

	public void setFromUser(String fromUser) {
		this.fromUser = fromUser;
	}

	public String getFromContact() {
		return fromContact;
	}

	public void setFromContact(String fromContact) {
		this.fromContact = fromContact;
	}

	public String getToName() {
		return toName;
	}

	public void setToName(String toName) {
		this.toName = toName;
	}

	public String getToAddress() {
		return toAddress;
	}

	public void setToAddress(String toAddress) {
		this.toAddress = toAddress;
	}

	public String getToUser() {
		return toUser;
	}

	public void setToUser(String toUser) {
		this.toUser = toUser;
	}

	public String getToContact() {
		return toContact;
	}

	public void setToContact(String toContact) {
		this.toContact = toContact;
	}

	public String getToZip() {
		return toZip;
	}

	public void setToZip(String toZip) {
		this.toZip = toZip;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getCost() {
		return cost;
	}

	public void setCost(String cost) {
		this.cost = cost;
	}

	public String getWeight() {
		return weight;
	}

	public void setWeight(String weight) {
		this.weight = weight;
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}
	
	public void populate(StockExpress exp){
		
		if(exp == null){return ;}
		exp.setExpressType(expressType);
		exp.setExpressNo(expressNo);
		exp.setFromAddress(fromAddress);
		exp.setFromContact(fromContact);
		exp.setFromName(fromName);
		exp.setFromUser(fromUser);
		
		exp.setToAddress(toAddress);
		exp.setToContact(toContact);
		exp.setToName(toName);
		exp.setToUser(toUser);
		exp.setToZip(toZip);
		
		exp.setNumber(Integer.parseInt(number));
		if(StringUtils.isNotBlank(cost)){
			exp.setCost(Float.parseFloat(cost));
		}
		if(StringUtils.isNotBlank(weight)){
			exp.setWeight(Float.parseFloat(weight));
		}
		exp.setSize(size);
		exp.setComments(comments);
		
	}
	
}
